/**
 * 简介: 创建常用的主题节点
 */
import ROSLIB from "roslib";
import { ros } from "./connect";
/**
 * 四元数主题
 */
var odom = new ROSLIB.Topic({
  ros: ros,
  name: "/odom",
  messageType: "nav_msgs/Odometry"
});

// 订阅ROS四元数信息的主题,获取节点并绑定
odom.subscribe(function () {
  // console.log(message);
  // console.log(
  //   "Received message on " +
  //     odom.name +
  //     ": " +
  //     message["pose"]["pose"]["position"]["x"]
  // );
  //   console.log("x:" + message["pose"]["pose"]["position"]["x"]);
  //   console.log("y:" + message["pose"]["pose"]["position"]["y"]);
  //   console.log("ox" + message["pose"]["pose"]["orientation"]["x"]);
  //   console.log("oy" + message["pose"]["pose"]["orientation"]["y"]);
  //   console.log("oz" + message["pose"]["pose"]["orientation"]["z"]);
  //   console.log("ow" + message["pose"]["pose"]["orientation"]["w"]);
});

/**
 * 运动控制主题
 */
var cmd_vel_listener = new ROSLIB.Topic({
  ros: ros,
  name: "/cmd_vel",
  messageType: "geometry_msgs/Twist"
});

/**
 * 订阅地图数据的主题
 */
var mapsTopic = new ROSLIB.Topic({
  ros: ros,
  name: "/map",
  messageType: "nav_msgs/OccupancyGrid"
});

/**
 * 发布字符串信息的主题
 */
var txt_listener = new ROSLIB.Topic({
  ros: ros,
  name: "/txt_msg",
  messageType: "std_msgs/String"
});

export {
  cmd_vel_listener,
  odom,
  txt_listener,
  mapsTopic
};
